package com.water.wfo.component.jdbc;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * packageName com.water.wfo.component.jdbc
 *
 * @author junhuili
 * @version JDK 8
 * @date 2023/10/29
 * @description 数据库配置
 */
@Component
@ConfigurationProperties(prefix = "datasource")
public class DataSourceProperties {
    /**
     * jdbc密码，主库
     */
    @Value("${jdbc.password.wfo}")
    private String jdbcPasswordMaster;

    private DruidDataSource master;

    @PostConstruct
    public void initPassword(){
        this.master.setPassword(jdbcPasswordMaster);
    }

    public String getJdbcPasswordMaster() {
        return jdbcPasswordMaster;
    }

    public void setJdbcPasswordMaster(String jdbcPasswordMaster) {
        this.jdbcPasswordMaster = jdbcPasswordMaster;
    }
    public DruidDataSource getMaster() {
        return master;
    }

    public void setMaster(DruidDataSource master) {
        this.master = master;
    }
}
